package com.lbd.smsplatform.controller;

import com.lbd.base.controller.BaseController;
import com.lbd.commons.Result;
import com.lbd.commons.ResultState;
import com.lbd.smsplatform.bean.SmsLog;
import com.lbd.smsplatform.service.SmsLogService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created by wang on 2016/9/23.
 */
@RestController
@RequestMapping("/sms")
public class SmsLogController extends BaseController {
    private final Logger log = Logger.getLogger(this.getClass());

    @Autowired
    SmsLogService smsService;

    /**
     * 1. 新增短信日志
     *
     * @param smsLog 短信日志bean
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Result add(SmsLog smsLog) {
        smsService.save(smsLog);
        return new Result(ResultState.SUCCESS, "成功！");

    }

    /**
     * 2. 短信日志列表
     *
     * @param page   页码
     * @param rows   行数
     * @param smsLog 短信日志bean
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result list(int page, int rows, SmsLog smsLog) {
        return new Result(ResultState.SUCCESS, "查询成功", smsService.findByPageConditionJpql(page, rows, smsLog));

    }
}
